package cn.zhf.shop.service.impl;

import cn.zhf.shop.entity.Message;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import cn.zhf.shop.mapper.OrderDetailMapper;
import cn.zhf.shop.entity.order.OrderDetail;
import cn.zhf.shop.service.OrderDetailService;

import java.util.List;

@Component
public class OrderDetailServiceImpl implements OrderDetailService{

    @Resource
    private OrderDetailMapper orderDetailMapper;

    @Override
    public int deleteByPrimaryKey(Integer id) {
        return orderDetailMapper.deleteByPrimaryKey(id);
    }

    @Override
    public Message insert(OrderDetail record) {
        return orderDetailMapper.insert(record)>0 ?Message.success(null):Message.fail("添加失败b");
    }

    @Override
    public OrderDetail selectByPrimaryKey(Integer id) {
        return orderDetailMapper.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKey(OrderDetail record) {
        return orderDetailMapper.updateByPrimaryKey(record);
    }

    @Override
    public Message<List<OrderDetail>> getByOrderId(String orderId) {
        List<OrderDetail> refund = orderDetailMapper.selectByOrderId(orderId);
        return refund==null ? Message.fail("无记录"):Message.success(null).add(refund);
    }


}
